package com.xiguanlezz.cn.consumer.handler;

import com.xiguanlezz.cn.codec.RpcDecoder;
import com.xiguanlezz.cn.codec.RpcEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @Author：习惯了种种
 * @CreateDate：2024/11/4 16:39
 * @Description：
 */
public class RpcConsumerInitializer extends ChannelInitializer<NioSocketChannel> {
    @Override
    protected void initChannel(NioSocketChannel nioSocketChannel) throws Exception {
        ChannelPipeline pipeline = nioSocketChannel.pipeline();
        pipeline.addLast(new LoggingHandler(LogLevel.DEBUG));
        pipeline.addLast(new RpcDecoder());
        pipeline.addLast(new RpcEncoder());
        pipeline.addLast(new RpcConsumerHandler());
    }
}
